/* Operators.cpp
Michael Zahniser, 12/12/09

Function definitions for the Operators class.
*/

#include "Operators.h"

#include <sstream>

using std::map;
using std::string;
using std::istringstream;



void Operators::Add(const Operator *op, const string &name)
{
	istringstream tokenize(name);
	string word;
	while(tokenize >> word)
		operators[word] = op;
}



bool Operators::Has(const string &name) const
{
	return operators.find(name) != operators.end();
}



const Operator &Operators::operator[](const std::string &name) const
{
	map<string, const Operator *>::const_iterator it = operators.find(name);
	if(it == operators.end())
	{
		static Operator noop;
		return noop;
	}
	return *it->second;
}
